﻿Shader "Unlit/ParticleRenderShader"
{
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog

            #include "UnityCG.cginc"

            /*
            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };
            */

            struct v2f
            {
                float4 color : COLOR0;
                //UNITY_FOG_COORDS(1)
                float4 vertex : SV_POSITION;
            };

            struct ParticleData
            {
                float3 pos;
                float4 color;
            };

            //Passed from: cs inited -> computeShader calculate -> renderShader render.
            StructuredBuffer<ParticleData> ParticleBuffer;

            v2f vert (uint id: SV_VERTEXID)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(float4(ParticleBuffer[id].pos, 0));
                o.color = ParticleBuffer[id].color;
                //UNITY_TRANSFER_FOG(o,o.vertex);
                return o;
            }

            fixed4 frag(v2f i) : SV_Target
            {
                // sample the texture
                fixed4 col = i.color;
                // apply fog
                //UNITY_APPLY_FOG(i.fogCoord, col);
                return col;
            }
            ENDCG
        }
    }
}
